const appData = getApp().globalData
const isLogin = (page) => {
  if (page.onShow) {
    let _onShow = page.onShow
    page.onShow = () => {
      let currentInstance = getPageInstance()
      if (appData.userInfo === null) {
        wx.redirectTo({
          url: '/pages/login/index?redirectUrl=' + currentInstance.route,
        })
      }
      _onShow.call(currentInstance)
    }
  }
  return page
}
function getPageInstance() {
  var pages = getCurrentPages()
  return pages[pages.length - 1]
}
exports.isLogin = isLogin